package com.xd.hbsys.aws;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xd.hbsys.aqi.AQIService;
import com.xd.hbsys.common.BaseService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class AWSController {
    @Autowired
    private AWSService awsService;

    @RequestMapping(value = "/aws/city/now")
    public String awscitynow() {

        return awsService.queryNow();

    }

    @RequestMapping(value = "/aws/city/query")
    public String awscityquery(@RequestParam(value = "time", required = false) String day) {

        return BaseService.RETURN_NULL;
    }

    @RequestMapping(value = "/aws/vis")
    public String awsvis(@RequestParam(value = "time") String time) {

        return awsService.queryVisibility(time);
    }

    @RequestMapping(value = "/aws/findAwsDayWindByCityCode")
    public Map<String, Object> findAwsDayWindByCityCode(String city_code, String date) {
        Map<String, Object> map = new HashMap<>();
        map.put("city_code", city_code);
        map.put("date", date);
        return awsService.findAwsDayWindByCityCode(map);
    }


    @RequestMapping(value = "/aws/findAwsDayWindByCityCode1")
    public Map<String, Object> findAwsDayWindByCityCode1(String city_code, String date) {
        String reg = "[^\u4e00-\u9fa5]";
        city_code = city_code.replaceAll(reg, "");
        String [] arr = date.split("\\s+");
        date = arr[0] + " 00:00";
        Map<String, Object> map = new HashMap<>();
        map.put("city_code", city_code.trim());
        map.put("date", date);
        Map<String, Object> map1 = new HashMap<>();
        map1 = awsService.findAwsDayWindByCityCode1(map);
        Map<String, Object> map2 = new HashMap<>();
        if (map1 == null) {
            map2.put("x", "");
            return map2;
        } else {
            return map1;
        }
    }


}
